home *** CD-ROM | disk | FTP | other *** search
- unit ntc_ciel_client_control;
- {
- Copyright (C) 2004 - 2006 Andrew Sprott
-
- http://astronomy.crysania.co.uk
- astro@trefach.co.uk
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- }
-
- interface
-
- uses
- Windows,
- Messages,
- SysUtils,
- Variants,
- Classes,
- Graphics,
- Controls,
- Forms,
- Dialogs,
- StdCtrls,
- ExtCtrls,
- Buttons,
- inifiles,
- ComCtrls,
-
- ntc_ciel_client_form;
-
- const
- { scope types }
- max_speeds=25;
- window_track_max=50;
- window_track_step=2;
- window_method=0;
- degree_method=1;
- window_percent_default=80;
- move_degrees_default=0;
- move_minutes_default=0;
- move_seconds_default=1;
- { basics }
- minutes_in_degree=60;
- seconds_in_minute=60;
- max_degrees=360;
- max_degrees_dec=90;
- max_hours=24;
- cr=#13;
-
- type
- buttons_type_set=(
- button_north,
- button_south,
- button_east,
- button_west);
- buttons_type=set of buttons_type_set;
-
- const
- buttons_all:buttons_type=[
- button_north,
- button_south,
- button_east,
- button_west];
-
- type
- Tscope_control = class(tform)
- control_panel: TPanel;
- slew_group: TGroupBox;
- north_button: TSpeedButton;
- east_button: TSpeedButton;
- west_button: TSpeedButton;
- south_button: TSpeedButton;
- stop_button: TSpeedButton;
- north_label: TLabel;
- west_label: TLabel;
- south_label: TLabel;
- east_label: TLabel;
- connect_group: TGroupBox;
- connect_button: TSpeedButton;
- disconnect_button: TSpeedButton;
- led_display: TEdit;
- goto_group: TGroupBox;
- ra_hours_edit: TEdit;
- ra_minutes_edit: TEdit;
- ra_seconds_edit: TEdit;
- dec_degrees_edit: TEdit;
- dec_minutes_edit: TEdit;
- dec_seconds_edit: TEdit;
- ra_label: TLabel;
- dec_label: TLabel;
- hours_label: TLabel;
- ra_minutes_label: TLabel;
- ra_seconds_label: TLabel;
- dec_minutes_label: TLabel;
- dec_seconds_label: TLabel;
- degrees_label: TLabel;
- goto_button: TBitBtn;
- locked_check: TCheckBox;
- ra_hours_up_down: TUpDown;
- dec_degrees_up_down: TUpDown;
- ra_minutes_up_down: TUpDown;
- dec_minutes_up_down: TUpDown;
- ra_seconds_up_down: TUpDown;
- dec_seconds_up_down: TUpDown;
- refresh_button: TBitBtn;
- move_units_group: TGroupBox;
- move_degrees_up_down: TUpDown;
- move_minutes_up_down: TUpDown;
- move_degrees_edit: TEdit;
- move_minutes_edit: TEdit;
- move_seconds_edit: TEdit;
- move_seconds_up_down: TUpDown;
- move_seconds_label: TLabel;
- move_minutes_label: TLabel;
- move_degrees_label: TLabel;
- window_move_button: TSpeedButton;
- degree_move_button: TSpeedButton;
- move_window_group: TGroupBox;
- degrees_edit: TEdit;
- window_track: TTrackBar;
- window_label: TLabel;
-
- { form functions }
- procedure formcreate(
- Sender:TObject);
-
- procedure form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
-
- { scope linkage }
- procedure flip_buttons(
- toggle:boolean);
-
- procedure change_panel(
- toggle:boolean);
-
- function connect_to_scope
- :boolean;
-
- function disconnect_from_scope
- :boolean;
-
- { directional controls }
- procedure stop_failed;
-
- procedure move_down;
- procedure move_up;
- procedure move_left;
- procedure move_right;
-
- procedure move_distance(
- d:string);
-
- procedure north_button_down(
- Sender:TObject);
-
- procedure south_button_down(
- Sender:TObject);
-
- procedure east_button_down(
- Sender:TObject);
-
- procedure west_button_down(
- Sender:TObject);
-
- procedure stop_button_down(
- Sender:TObject);
-
- procedure stop_scope;
-
- { goto }
- procedure go_to;
-
- { speed controls }
- procedure update_speed_group(
- speed_box:tpanel;
- first_speed_button:tspeedbutton;
- start_speed,
- speed_count:integer;
- event:TNotifyEvent;
- can_do:boolean);
-
- function set_slew_speed(
- speed_box:tpanel)
- :integer;
-
- { logging }
- procedure write_status_log(
- e:string);
-
- { configuration }
- procedure load_settings;
-
- procedure save_settings;
-
- { utilites }
- procedure change_window_method;
- procedure change_degree_method;
-
- procedure update_degrees;
-
- procedure update_edit_boxes;
- procedure update_ra_edit_boxes;
- procedure update_dec_edit_boxes;
-
- { events }
- procedure FormShow(
- Sender:TObject);
-
- procedure adjust;
-
- procedure check_activate(
- Sender: TObject);
-
- procedure east_labelClick(
- Sender: TObject);
-
- procedure west_labelClick(
- Sender: TObject);
-
- procedure north_labelClick(
- Sender: TObject);
-
- procedure south_labelClick(
- Sender: TObject);
-
- procedure disconnect_from_scope_click(
- Sender:TObject);
-
- procedure connect_to_scope_click(
- sender:tobject);
-
- procedure goto_buttonClick(
- Sender: TObject);
-
- procedure window_move_buttonClick(
- Sender: TObject);
-
- procedure degree_move_buttonClick(
- Sender: TObject);
-
- procedure window_trackChange(
- Sender: TObject);
-
- procedure degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure move_degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure move_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure move_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure move_degrees_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure move_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure move_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure move_degrees_editEnter(
- Sender: TObject);
-
- procedure ra_hours_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure ra_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure ra_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure dec_degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure dec_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure dec_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
-
- procedure ra_hours_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure ra_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure ra_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure dec_degrees_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure dec_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure dec_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
-
- procedure move_degrees_editChange(
- Sender: TObject);
-
- procedure move_minutes_editChange(
- Sender: TObject);
-
- procedure move_seconds_editChange(
- Sender: TObject);
-
- private
- { Private declarations }
- north_south_reversed,
- east_west_reversed:boolean;
- public
- { Public declarations }
- moving_scope:boolean;
- scope_name:shortstring;
- ignore_event_north,
- ignore_event_south,
- ignore_event_west,
- ignore_event_east:longint;
- can_slew,
- can_goto,
- can_sync:boolean;
- { configuration }
- dimensions:dimensions_record;
- { slew controls }
- move_method:integer;
- { window method }
- window_percent:extended;
- { degree method }
- move_degrees,
- move_minutes,
- move_seconds:extended;
- degrees_updating,
- minutes_updating,
- seconds_updating,
- ra_hours_updating,
- ra_minutes_updating,
- ra_seconds_updating,
- dec_degrees_updating,
- dec_minutes_updating,
- dec_seconds_updating:boolean;
-
- procedure normalise(
- max_degrees:integer;
- var degrees,
- minutes,
- seconds:extended);
-
- { events }
- procedure check_visible_and_show_hide(
- sender:tobject);
-
- procedure hide_form;
- procedure show_form;
- end;
-
- { global variables }
- var
- scope_control:Tscope_control;
-
- implementation
-
- uses
- ntc_ciel_client_network,
- ntc_ciel_client_info,
- ntc_ciel_client_focus,
- ntc_ciel_client_tracking,
- ntc_ciel_client_object,
- ntc_ciel_client_search;
-
- {$R *.dfm}
-
- { -------------
- form controls
- ------------- }
-
- procedure tscope_control.formcreate(
- Sender:TObject);
- begin
- ignore_event_north:=event_0;
- ignore_event_south:=event_0;
- ignore_event_east:=event_0;
- ignore_event_west:=event_0;
- flip_buttons(false);
- move_degrees_up_down.max:=max_degrees-1;
- move_minutes_up_down.max:=minutes_in_degree-1;
- move_seconds_up_down.max:=seconds_in_minute-1;
- move_degrees_up_down.min:=0;
- move_minutes_up_down.min:=0;
- move_seconds_up_down.min:=0;
- { goto }
- ra_hours_up_down.min:=0;
- ra_minutes_up_down.min:=0;
- ra_seconds_up_down.min:=0;
- dec_degrees_up_down.min:=0;
- dec_minutes_up_down.min:=0;
- dec_seconds_up_down.min:=0;
- ra_hours_up_down.max:=max_hours-1;
- ra_minutes_up_down.max:=minutes_in_degree-1;
- ra_seconds_up_down.max:=seconds_in_minute-1;
- dec_degrees_up_down.max:=max_degrees_dec-1;
- dec_minutes_up_down.max:=minutes_in_degree-1;
- dec_seconds_up_down.max:=seconds_in_minute-1;
- { temporary }
- can_slew:=true;
- window_track.min:=0;
- window_track.max:=window_track_max;
- degrees_updating:=false;
- minutes_updating:=false;
- seconds_updating:=false;
- ra_hours_updating:=false;
- ra_minutes_updating:=false;
- ra_seconds_updating:=false;
- dec_degrees_updating:=false;
- dec_minutes_updating:=false;
- dec_seconds_updating:=false;
- load_settings;
- moving_scope:=false;
- visible:=false;
- end;
-
- procedure Tscope_control.form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
- begin
- visible:=false;
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- if ciel_closing then
- canclose:=true
- else
- canclose:=false;
- end;
-
- { -------------
- scope linkage
- ------------- }
-
- procedure Tscope_control.flip_buttons(
- toggle:boolean);
- begin
- slew_group.enabled:=toggle;
- if toggle then
- begin
- if move_method=window_method then
- change_window_method
- else
- change_degree_method;
- end
- else
- begin
- move_window_group.enabled:=false;
- move_units_group.Enabled:=false;
- end;
- east_button.enabled:=toggle;
- north_button.enabled:=toggle;
- west_button.enabled:=toggle;
- south_button.enabled:=toggle;
- stop_button.enabled:=toggle;
- goto_group.enabled:=toggle;
- end;
-
- function send_request(
- m,
- e:string)
- :response_type;
- begin
- result:=scope_network.send_request(m,e);
- end;
-
- function send_request_check(
- m:string)
- :response_type;
- begin
- result:=scope_network.send_request_check(m);
- end;
-
- procedure Tscope_control.change_panel(
- toggle:boolean);
- begin
- if toggle then
- begin
- if not moving_scope then
- begin
- led_display.color:=clRed;
- led_display.refresh;
- end;
- if can_slew then
- flip_buttons(true);
- with scope_focus do
- if can_focus then
- begin
- update_speed_group(
- speed_box,
- first_speed_button,
- start_focus_speed,
- focus_speeds,
- speed_button_click,
- can_focus);
- flip_buttons(true);
- end
- else
- flip_buttons(false);
- with scope_tracking do
- if can_track then
- flip_buttons(true);
- scope_search.enable_panel;
- if not moving_scope then
- begin
- led_display.color:=clLime;
- led_display.refresh;
- end;
- connect_button.Enabled:=not toggle;
- disconnect_button.enabled:=toggle;
- end
- else
- begin
- scope_focus.flip_buttons(false);
- scope_tracking.flip_buttons(false);
- scope_search.disable_panel;
- flip_buttons(false);
- if not moving_scope then
- begin
- led_display.color:=clred;
- led_display.refresh;
- connect_button.Enabled:=not toggle;
- end;
- disconnect_button.enabled:=toggle;
- end;
- if scope_focus.focused then
- scope_focus.show;
- if focused then
- Show;
- end;
-
- function Tscope_control.connect_to_scope
- :boolean;
- begin
- if send_request('connect','Connection to scope failed')>=[exit_ok] then
- begin
- scope_info.get_info;
- change_panel(true);
- result:=true;
- end
- else
- result:=false;
- end;
-
- function tscope_control.disconnect_from_scope
- :boolean;
- begin
- if send_request_check('disconnect')>=[exit_ok] then
- with scope_control do
- begin
- led_display.color:=clRed;
- led_display.refresh;
- change_panel(false);
- if focused then
- show;
- result:=true;
- end
- else
- result:=false;
- end;
-
- { -------------------
- directional buttons
- ------------------- }
-
- procedure tscope_control.stop_failed;
- begin
- showmessage(stop_error);
- end;
-
- procedure tscope_control.move_down;
- begin
- scope_search.move_screen('down');
- end;
-
- procedure tscope_control.move_up;
- begin
- scope_search.move_screen('up');
- end;
-
- procedure tscope_control.move_left;
- begin
- scope_search.move_screen('left');
- end;
-
- procedure tscope_control.move_right;
- begin
- scope_search.move_screen('right');
- end;
-
- procedure tscope_control.move_distance(
- d:string);
- var
- t_ra:double;
- begin
- t_ra:=move_seconds/seconds_in_minute;
- t_ra:=(t_ra+move_minutes)/minutes_in_degree;
- t_ra:=t_ra+move_degrees;
- scope_network.send_request_check('move_'+d+'(distance='+floattostr(t_ra)+')');
- scope_search.enable_timer;
- end;
-
- procedure tscope_control.north_button_down(
- Sender:TObject);
- begin
- if not moving_scope then
- begin
- moving_scope:=true;
- write_status_log('north - begin');
- if move_method=window_method then
- begin
- if north_label.caption='N' then
- move_up
- else
- move_down;
- end
- else if move_degrees+move_minutes+move_seconds>0 then
- move_distance('up')
- else
- moving_scope:=false;
- write_status_log('north - end');
- end;
- end;
-
- procedure tscope_control.south_button_down(
- Sender:TObject);
- begin
- if not moving_scope then
- begin
- moving_scope:=true;
- write_status_log('south - begin');
- if move_method=window_method then
- begin
- if north_label.caption='S' then
- move_up
- else
- move_down;
- end
- else if move_degrees+move_minutes+move_seconds>0 then
- move_distance('down')
- else
- moving_scope:=false;
- write_status_log('south - end');
- end;
- end;
-
- procedure tscope_control.east_button_down(
- Sender:TObject);
- begin
- if not moving_scope then
- begin
- moving_scope:=true;
- write_status_log('east - begin');
- if move_method=window_method then
- begin
- if north_label.caption='W' then
- move_left
- else
- move_right;
- end
- else if move_degrees+move_minutes+move_seconds>0 then
- move_distance('right')
- else
- moving_scope:=false;
- write_status_log('east - end');
- end;
- end;
-
- procedure tscope_control.west_button_down(
- Sender:TObject);
- begin
- if not moving_scope then
- begin
- moving_scope:=true;
- write_status_log('west - begin');
- if move_method=window_method then
- begin
- if north_label.caption='E' then
- move_left
- else
- move_right;
- end
- else if move_degrees+move_minutes+move_seconds>0 then
- move_distance('left')
- else
- moving_scope:=false;
- write_status_log('west - end');
- end;
- end;
-
- procedure tscope_control.stop_scope;
- begin
- if not (send_request_check('stop')>=[exit_ok]) then
- stop_failed;
- end;
-
- procedure tscope_control.stop_button_down(
- Sender:TObject);
- begin
- stop_scope;
- end;
-
- { ----
- goto
- ---- }
-
- procedure tscope_control.go_to;
- begin
- with current_object do
- begin
- ra:=strtointdef(ra_seconds_edit.text,0)/60;
- ra:=(ra+strtointdef(ra_minutes_edit.text,0)/60);
- ra:=ra+strtointdef(ra_hours_edit.text,0);
- dec:=strtointdef(dec_seconds_edit.text,0)/60;
- dec:=(dec+strtointdef(dec_minutes_edit.text,0)/60);
- dec:=dec+strtointdef(dec_degrees_edit.text,0);
- send_request_check('goto(ra='+floattostr(ra)+',dec='+floattostr(dec)+')');
- end;
- end;
-
- { --------------
- speed controls
- -------------- }
-
- procedure tscope_control.update_speed_group(
- speed_box:tpanel;
- first_speed_button:tspeedbutton;
- start_speed,
- speed_count:integer;
- event:TNotifyEvent;
- can_do:boolean);
- var
- c,i,j,k,bh,bw,bl,bt:integer;
- n,l,r,t:tspeedbutton;
- x,y:extended;
- begin
- if can_do then
- with speed_box do
- begin
- r:=first_speed_button;
- n:=tspeedbutton(r.tag);
- i:=speed_count;
- while n<>nil do
- begin
- l:=n;
- n:=tspeedbutton(n.tag);
- dec(i);
- if i<=0 then
- begin
- if i=0 then
- begin
- t:=tspeedbutton(r.tag);
- r.Tag:=longint(nil);
- r:=t;
- end
- else
- r:=tspeedbutton(r.tag);
- l.free;
- end
- else
- r:=tspeedbutton(r.tag);
- end;
- while i>1 do
- begin
- r.tag:=longint(tspeedbutton.create(self));
- r:=tspeedbutton(r.tag);
- r.tag:=longint(nil);
- r.Parent:=speed_box;
- dec(i);
- end;
- x:=speed_count;
- i:=trunc(sqrt(x));
- if i>1 then
- begin
- y:=sqr(i+1);
- j:=trunc(sqrt(y));
- k:=speed_count div j;
- if (k>=i) and (speed_count mod j<>0) then
- begin
- k:=-1;
- inc(i);
- end;
- end
- else
- k:=0;
- if height>=width then
- begin
- if i<=1 then
- begin
- if speed_count>1 then
- bh:=height div speed_count
- else
- begin
- bh:=height;
- i:=1
- end;
- end
- else if (k>=0) and ((speed_count mod i<>0) or (k>=i)) then
- bh:=height div (i+1)
- else
- bh:=height div i;
- n:=first_speed_button;
- if i>1 then
- bw:=width div i
- else
- begin
- bw:=width;
- n.Caption:=inttostr(start_speed);
- end;
- end
- else
- begin
- if i<=1 then
- begin
- if speed_count>1 then
- bw:=width div speed_count
- else
- begin
- bw:=width;
- i:=1
- end;
- end
- else if (k>=0) and ((speed_count mod i<>0) or (k>=i)) then
- bw:=width div (i+1)
- else
- bw:=width div i;
- n:=first_speed_button;
- if i>1 then
- bh:=height div i
- else
- begin
- bh:=height;
- n.Caption:=inttostr(start_speed);
- end;
- end;
- bl:=0;
- bt:=0;
- c:=start_speed;
- while n<>nil do
- with n do
- begin
- Width:=bw;
- top:=bt;
- left:=bl;
- inc(bl,bw);
- with speed_box do
- if height>=width then
- begin
- if bl+(bw div 2)>width then
- begin
- bl:=0;
- inc(bt,bh);
- end;
- end
- else if bt+(bh div 2)>Height then
- begin
- bt:=0;
- inc(bl,bw);
- end;
- Height:=bh;
- down:=false;
- groupindex:=1;
- allowallup:=false;
- caption:=inttostr(c);
- visible:=true;
- enabled:=true;
- onclick:=event;
- inc(c);
- n:=tspeedbutton(Tag);
- end;
- first_speed_button.down:=true;
- end;
- end;
-
- function tscope_control.set_slew_speed(
- speed_box:tpanel)
- :integer;
- var
- i:integer;
- begin
- result:=1;
- for I:= 0 to speed_box.ControlCount -1 do
- begin
- if tspeedbutton(speed_box.controls[i]).down=true then
- begin
- result:=strtointdef(tspeedbutton(speed_box.controls[i]).caption,i+1);
- exit;
- end;
- end;
- end;
-
- { -------
- logging
- ------- }
-
- procedure tscope_control.write_status_log(
- e:string);
- begin
- scope_network.write_status_log_check(e);
- end;
-
- { -------------
- configuration
- ------------- }
-
- procedure tscope_control.load_settings;
- begin
- ini_file:=tinifile.create(application_path+'ciel.ini');
- with ini_file do
- begin
- move_method:=readinteger('control','move_method',window_method);
- window_percent:=
- readfloat('control','window_percent',window_percent_default);
- move_degrees:=readfloat('control','move_degrees',move_degrees_default);
- move_minutes:=readfloat('control','move_minutes',move_minutes_default);
- move_seconds:=readfloat('control','move_seconds',move_seconds_default);
- window_track.Position:=trunc(window_percent) div window_track_step;
- degrees_edit.text:=floattostr(window_percent);
- update_degrees;
- move_degrees_up_down.position:=trunc(move_degrees);
- move_minutes_up_down.position:=trunc(move_minutes);
- move_seconds_up_down.position:=trunc(move_seconds);
- if move_method=window_method then
- window_move_button.down:=true
- else
- degree_move_button.down:=true;
- north_south_reversed:=ReadBool('control','swap_north_south',false);
- east_west_reversed:=ReadBool('control','swap_east_west',false);
- can_goto:=ReadBool('control','can_goto',false);
- can_sync:=ReadBool('control','can_sync',false);
- if north_south_reversed then
- begin
- north_label.Caption:='S';
- south_label.caption:='N';
- end
- else
- begin
- north_label.Caption:='N';
- south_label.caption:='S';
- end;
- if east_west_reversed then
- begin
- east_label.Caption:='W';
- west_label.caption:='E';
- end
- else
- begin
- east_label.Caption:='E';
- west_label.caption:='W';
- end;
- locked_check.checked:=true;
- { form }
- scope.get_dimensions(scope_control,@dimensions,'control',ini_file);
- left:=dimensions.form_left;
- top:=dimensions.form_top;
- visible:=readbool('control','visible',false);
- end;
- ini_file.free;
- end;
-
- procedure tscope_control.save_settings;
- begin
- with ini_file do
- begin
- writeinteger('control','move_method',move_method);
- writefloat('control','window_percent',window_percent);
- writefloat('control','move_degrees',move_degrees);
- writefloat('control','move_minutes',move_minutes);
- writefloat('control','move_seconds',move_seconds);
- writeBool('control','swap_north_south',north_south_reversed);
- writeBool('control','swap_east_west',east_west_reversed);
- writeBool('control','can_goto',can_goto);
- writeBool('control','can_sync',can_sync);
- { form }
- scope.find_vdu(scope_control,@dimensions);
- scope.write_dimensions(@dimensions,left,top,'control',ini_file);
- writebool('control','visible',visible);
- end;
- end;
-
- { --------
- utilites
- -------- }
-
- procedure Tscope_control.change_window_method;
- begin
- move_units_group.enabled:=false;
- move_degrees_edit.enabled:=false;
- move_minutes_edit.enabled:=false;
- move_seconds_edit.enabled:=false;
- move_degrees_up_down.Enabled:=false;
- move_minutes_up_down.Enabled:=false;
- move_seconds_up_down.Enabled:=false;
- move_degrees_label.Enabled:=false;
- move_minutes_label.Enabled:=false;
- move_seconds_label.Enabled:=false;
- window_track.Enabled:=true;
- degrees_edit.enabled:=true;
- move_window_group.enabled:=true;
- move_method:=window_method;
- window_move_button.down:=true;
- end;
-
- procedure Tscope_control.change_degree_method;
- begin
- move_window_group.enabled:=false;
- window_track.Enabled:=false;
- degrees_edit.enabled:=false;
- move_degrees_edit.enabled:=true;
- move_minutes_edit.enabled:=true;
- move_seconds_edit.enabled:=true;
- move_degrees_up_down.Enabled:=true;
- move_minutes_up_down.Enabled:=true;
- move_seconds_up_down.Enabled:=true;
- move_degrees_label.Enabled:=true;
- move_minutes_label.Enabled:=true;
- move_seconds_label.Enabled:=true;
- move_units_group.enabled:=true;
- move_method:=degree_method;
- degree_move_button.down:=true;
- end;
-
- procedure Tscope_control.normalise(
- max_degrees:integer;
- var degrees,
- minutes,
- seconds:extended);
- begin
- if (degrees>0) and (degrees>=max_degrees) then
- degrees:=max_degrees-1
- else if (degrees<0) and (degrees<=-max_degrees) then
- degrees:=-(max_degrees-1);
- if frac(degrees)<>0 then
- begin
- minutes:=0;
- seconds:=0;
- minutes:=frac(degrees)*minutes_in_degree;
- degrees:=trunc(degrees);
- seconds:=frac(minutes)*seconds_in_minute;
- minutes:=trunc(minutes);
- end
- else if frac(minutes)<>0 then
- begin
- seconds:=0;
- seconds:=frac(minutes)*seconds_in_minute;
- minutes:=trunc(minutes);
- end;
- end;
-
- procedure Tscope_control.update_degrees;
- begin
- normalise(max_degrees,move_degrees,move_minutes,move_seconds);
- end;
-
- procedure Tscope_control.update_edit_boxes;
- begin
- move_degrees:=strtofloatdef(move_degrees_edit.text,move_degrees);
- move_minutes:=strtofloatdef(move_minutes_edit.text,move_minutes);
- move_seconds:=strtofloatdef(move_seconds_edit.text,move_seconds);
- update_degrees;
- move_degrees_edit.text:=floattostr(move_degrees);
- move_minutes_edit.Text:=floattostr(move_minutes);
- move_seconds_edit.text:=floattostr(move_seconds);
- move_degrees_up_down.position:=trunc(move_degrees);
- move_minutes_up_down.position:=trunc(move_minutes);
- move_seconds_up_down.position:=trunc(move_seconds);
- end;
-
- { ------
- events
- ------ }
-
- procedure Tscope_control.FormShow(
- Sender:TObject);
- begin
- with dimensions do
- begin
- top:=form_top;
- left:=form_left;
- end;
- end;
-
- procedure tscope_control.adjust;
- begin
- with dimensions do
- begin
- form_top:=trunc(form_top/last_screen_height*current_height);
- form_left:=trunc(form_left/last_screen_width*current_width);
- end;
- if visible then
- show;
- end;
-
- procedure tscope_control.check_visible_and_show_hide(
- sender:tobject);
- begin
- if visible then
- hide_form
- else
- show_form;
- scope.show_hide(sender,visible);
- end;
-
- procedure tscope_control.hide_form;
- begin
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- Visible:=false;
- formstyle:=fsnormal;
- end;
-
- procedure tscope_control.show_form;
- begin
- formstyle:=fsstayontop;
- Visible:=true;
- end;
-
- procedure Tscope_control.check_activate(
- Sender: TObject);
- begin
- scope.form_activate(scope_control,@dimensions);
- end;
-
- procedure Tscope_control.east_labelClick(
- Sender: TObject);
- begin
- if not locked_check.checked then
- begin
- east_west_reversed:=east_label.caption='E';
- if east_west_reversed then
- begin
- east_label.caption:='W';
- west_label.caption:='E';
- end
- else
- begin
- east_label.caption:='E';
- west_label.caption:='W';
- end;
- end;
- end;
-
- procedure Tscope_control.west_labelClick(
- Sender: TObject);
- begin
- if not locked_check.checked then
- begin
- east_west_reversed:=west_label.caption='W';
- if east_west_reversed then
- begin
- east_label.caption:='W';
- west_label.caption:='E';
- end
- else
- begin
- east_label.caption:='E';
- west_label.caption:='W';
- end;
- end;
- end;
-
- procedure Tscope_control.north_labelClick(
- Sender: TObject);
- begin
- if not locked_check.checked then
- begin
- north_south_reversed:=north_label.caption='N';
- if north_south_reversed then
- begin
- north_label.caption:='S';
- south_label.caption:='N';
- end
- else
- begin
- north_label.caption:='N';
- south_label.caption:='S';
- end;
- end;
- end;
-
- procedure Tscope_control.south_labelClick(
- Sender: TObject);
- begin
- if not locked_check.checked then
- begin
- north_south_reversed:=south_label.caption='S';
- if north_south_reversed then
- begin
- north_label.caption:='S';
- south_label.caption:='N';
- end
- else
- begin
- north_label.caption:='N';
- south_label.caption:='S';
- end;
- end;
- end;
-
- procedure tscope_control.connect_to_scope_click(
- sender:tobject);
- begin
- if scope_network.scope_client.connected and not moving_scope then
- connect_to_scope;
- end;
-
- procedure Tscope_control.disconnect_from_scope_click(
- Sender:TObject);
- begin
- if scope_network.scope_client.connected and not moving_scope then
- disconnect_from_scope;
- end;
-
- procedure Tscope_control.goto_buttonClick(
- Sender: TObject);
- begin
- go_to;
- end;
-
- procedure Tscope_control.degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
- var
- t:extended;
- begin
- if key=cr then
- begin
- t:=strtofloatdef(degrees_edit.text,0.5);
- if (t<=100) and (t>=0) then
- begin
- move_degrees:=t;
- window_track.position:=trunc(t) div window_track_step;
- end;
- end;
- end;
-
- procedure Tscope_control.window_trackChange(
- Sender: TObject);
- begin
- with window_track do
- begin
- window_percent:=position*window_track_step;
- degrees_edit.text:=floattostr(window_percent);
- end;
- end;
-
- procedure Tscope_control.window_move_buttonClick(
- Sender: TObject);
- begin
- change_window_method;
- end;
-
- procedure Tscope_control.degree_move_buttonClick(
- Sender: TObject);
- begin
- change_degree_method;
- end;
-
- procedure Tscope_control.move_degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_edit_boxes;
- end;
-
- procedure Tscope_control.move_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_edit_boxes;
- end;
-
- procedure Tscope_control.move_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_edit_boxes;
- end;
-
- procedure Tscope_control.move_degrees_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not degrees_updating then
- begin
- degrees_updating:=true;
- update_edit_boxes;
- degrees_updating:=false;
- end;
- end;
-
- procedure Tscope_control.move_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not minutes_updating then
- begin
- minutes_updating:=true;
- update_edit_boxes;
- minutes_updating:=false;
- end;
- end;
-
- procedure Tscope_control.move_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not seconds_updating then
- begin
- seconds_updating:=true;
- update_edit_boxes;
- seconds_updating:=false;
- end;
- end;
-
- procedure Tscope_control.move_degrees_editEnter(
- Sender: TObject);
- begin
- update_edit_boxes;
- end;
-
- procedure Tscope_control.update_ra_edit_boxes;
- var
- ra_h,ra_m,ra_s:extended;
- begin
- ra_h:=strtofloatdef(ra_hours_edit.text,0);
- ra_m:=strtofloatdef(ra_minutes_edit.text,0);
- ra_s:=strtofloatdef(ra_seconds_edit.text,0);
- normalise(max_hours,ra_h,ra_m,ra_s);
- ra_hours_edit.text:=floattostr(ra_h);
- ra_minutes_edit.Text:=floattostr(ra_m);
- ra_seconds_edit.text:=floattostr(ra_s);
- ra_hours_up_down.position:=trunc(ra_h);
- ra_minutes_up_down.position:=trunc(ra_m);
- ra_seconds_up_down.position:=trunc(ra_s);
- end;
-
- procedure Tscope_control.ra_hours_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_ra_edit_boxes;
- end;
-
- procedure Tscope_control.ra_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_ra_edit_boxes;
- end;
-
- procedure Tscope_control.ra_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_ra_edit_boxes;
- end;
-
- procedure Tscope_control.update_dec_edit_boxes;
- var
- dec_d,dec_m,dec_s:extended;
- begin
- dec_d:=strtofloatdef(dec_degrees_edit.text,0);
- dec_m:=strtofloatdef(dec_minutes_edit.text,0);
- dec_s:=strtofloatdef(dec_seconds_edit.text,0);
- normalise(max_degrees_dec,dec_d,dec_m,dec_s);
- dec_degrees_edit.text:=floattostr(dec_d);
- dec_minutes_edit.Text:=floattostr(dec_m);
- dec_seconds_edit.text:=floattostr(dec_s);
- dec_degrees_up_down.position:=trunc(dec_d);
- dec_minutes_up_down.position:=trunc(dec_m);
- dec_seconds_up_down.position:=trunc(dec_s);
- end;
-
- procedure Tscope_control.dec_degrees_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_dec_edit_boxes;
- end;
-
- procedure Tscope_control.dec_minutes_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_dec_edit_boxes;
- end;
-
- procedure Tscope_control.dec_seconds_editKeyPress(
- Sender: TObject;
- var Key: Char);
- begin
- if key=cr then
- update_dec_edit_boxes;
- end;
-
- procedure Tscope_control.ra_hours_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not ra_hours_updating then
- begin
- ra_hours_updating:=true;
- update_ra_edit_boxes;
- ra_hours_updating:=false;
- end;
- end;
-
- procedure Tscope_control.ra_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not ra_minutes_updating then
- begin
- ra_minutes_updating:=true;
- update_ra_edit_boxes;
- ra_minutes_updating:=false;
- end;
- end;
-
- procedure Tscope_control.ra_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not ra_seconds_updating then
- begin
- ra_seconds_updating:=true;
- update_ra_edit_boxes;
- ra_seconds_updating:=false;
- end;
- end;
-
- procedure Tscope_control.dec_degrees_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not dec_degrees_updating then
- begin
- dec_degrees_updating:=true;
- update_dec_edit_boxes;
- dec_degrees_updating:=false;
- end;
- end;
-
- procedure Tscope_control.dec_minutes_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not dec_minutes_updating then
- begin
- dec_minutes_updating:=true;
- update_dec_edit_boxes;
- dec_minutes_updating:=false;
- end;
- end;
-
- procedure Tscope_control.dec_seconds_up_downChanging(
- Sender: TObject;
- var AllowChange: Boolean);
- begin
- if not dec_seconds_updating then
- begin
- dec_seconds_updating:=true;
- update_dec_edit_boxes;
- dec_seconds_updating:=false;
- end;
- end;
-
- procedure Tscope_control.move_degrees_editChange(
- Sender: TObject);
- begin
- update_edit_boxes;
- end;
-
- procedure Tscope_control.move_minutes_editChange(
- Sender: TObject);
- begin
- update_edit_boxes;
- end;
-
- procedure Tscope_control.move_seconds_editChange(
- Sender: TObject);
- begin
- update_edit_boxes;
- end;
-
- end.
-